#include <iostream>
#include <cstring>
using namespace std;


template <typename Item>
class Array
{
public:
    friend ostream& operator<<(ostream& os, const Array<Item> & array);
    Item& operator[](int index);
private:
    Item * m_data;
    int m_size;
    int m_capacity;

public:
    Array() : Array(10){}

    Array(int capacity)
    {
        if (capacity <= 0)
        {
            capacity = 10;
        }

        m_data = new Item[capacity];
        if (m_data == NULL)
        {
            throw "new error";
        }
        memset(m_data, 0, sizeof(Item) * capacity);
        m_size = 0;
        m_capacity = capacity;
    }

    /* 析构函数*/
    ~Array()
    {
        if (m_data)
        {
            delete []m_data;
        }
    }


public:
    void add(Item value);
    Item get(int index);
};
template <typename Item>
ostream& operator<<(ostream& os, const Array<Item> & array)
{
    for(int idx = 0; idx < array.m_size; idx++)
    {
        os << array.m_data << endl;
    }
    return os;
}
template <typename Item>
Item& Array<Item>::operator[](int index)
{
    return this->m_data[index];
}

template <typename Item>
void Array<Item>::add(Item value)
{
    if (this->m_size == m_capacity)
    {
        /* 扩容*/
    }
    /* 程序到这里空间一定够*/
    m_data[m_size++] = value;
    return;
}

template <typename Item>
Item Array<Item>::get(int index)
{
    
}


int main()
{
    Array<int> array1;
    return 0;
}